package com.Isb.Golf.inputgolfscore;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView.BufferType;

public class SettingActivity extends Activity {
	private EditText nameEditText;
	private Button endbutton;

    private InputGolfScoreModel appModel;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting);
		findViews();
		setListeners();

		appModel = InputGolfScoreModel.getInstance();
		String inputName = appModel.LoadPlayerName();
		nameEditText.setText(inputName, BufferType.NORMAL);
	}

	protected void findViews(){
		nameEditText = (EditText)findViewById(R.id.editText_Name);
		endbutton = (Button)findViewById(R.id.ok_button);
	}

	protected void setListeners(){
		endbutton.setOnClickListener(new OnClickListener(){
			public void onClick(View v){
				String inputName = nameEditText.getText().toString();
				appModel.SavePlayerName(inputName);
				finish();
			}
		});
	}

}
